Class symantec.itools.awt.Matrix
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class symantec.itools.awt.Matrix

Object
   |
   +----symantec.itools.awt.Matrix

public final class Matrix
extends Object
implements Serializable
This class implements a sparse matrix of objects.

Version:
1.0, Nov 26, 1996
Author:
Symantec

Variable Index

 o errors
Error strings.

Constructor Index

 o symantec.itools.awt.Matrix()
Constructs an empty matrix.

Method Index

 o addElement(int, int, Object)
Adds the given element to this matrix at the specified row and column.
 o elementAt(int, int)
Returns the element at the specified row and column.
 o elements()
Returns an enumeration of all the elements.
 o insertRow(int)
Inserts a new row at the given location.
 o printRow(int)
Prints the specified row to System.out.
 o removeAllElements()
Removes all elements of the matrix.
 o removeElementAt(int, int)
Deletes the element at the specified row and column.
 o removeRow(int)
Deletes all elements on the specified row.
 o rows()
Returns the number of rows in the matrix.
 o sort(CompareFunc, int)
Sorts all rows into ascending order.
 o toString()
Returns a string representation of this component.
 o updateElement(int, int, Object)
Adds or updates the element at the specified row and column, as needed.

Variables

 o errors
protected transient java.util.ResourceBundle errors
Error strings.

Constructors

 o Matrix
public Matrix()
Constructs an empty matrix.

Methods

 o addElement
public synchronized void addElement(int r,
                                    int c,
                                    Object o) throws IllegalArgumentException
Adds the given element to this matrix at the specified row and column.

Parameters:
r - the row of the element to be added
c - the column of the element to added
o - the element to be added
Throws: IllegalArgumentException
if an element is already allocated at [r,c]
See Also:
updateElement, removeElementAt
 o elementAt
public synchronized java.lang.Object elementAt(int r,
                                               int c) throws ArrayIndexOutOfBoundsException
Returns the element at the specified row and column.

Parameters:
r - the row of the element to return
c - the column of the element to return
Returns:
the element at [r,c]
Throws: ArrayIndexOutOfBoundsException
if an invalid row and/or column was given
 o elements
public synchronized symantec.itools.awt.MatrixEnumeration elements()
Returns an enumeration of all the elements. Use the enumeration methods of the returned object to fetch the elements sequentially.

 o insertRow
public synchronized void insertRow(int r)
Inserts a new row at the given location. It does this by incrementing the row number of all elements with row indexes >= given row number.

Parameters:
r - the number of the row to insert
See Also:
removeRow
 o printRow
public synchronized void printRow(int r)
Prints the specified row to System.out. This can be handy for debugging purposes.

Parameters:
r - the row to print
 o removeAllElements
public synchronized void removeAllElements()
Removes all elements of the matrix. The matrix becomes empty.

See Also:
addElement, removeElementAt
 o removeElementAt
public synchronized void removeElementAt(int r,
                                         int c) throws ArrayIndexOutOfBoundsException
Deletes the element at the specified row and column.

Parameters:
r - the row of the element to remove
c - the column of the element to remove
Throws: ArrayIndexOutOfBoundsException
if an invalid row and/or column was given
 o removeRow
public synchronized void removeRow(int r)
Deletes all elements on the specified row.

Parameters:
r - the row of the elements to remove
See Also:
insertRow, removeElementAt
 o rows
public synchronized int rows()
Returns the number of rows in the matrix.

 o sort
public synchronized void sort(CompareFunc f,
                              int c)
Sorts all rows into ascending order. It does this by comparing elements at the given column number using the provided CompareFunc.

Parameters:
f - compares two objects and determines which one is less than the other
c - the column number of elements to compare
 o toString
public synchronized java.lang.String toString()
Returns a string representation of this component. This is a standard Java AWT method which gets called to generate a string that represents this component.

Returns:
a meaningful string about this object
Overrides:
toString in class Object
 o updateElement
public synchronized void updateElement(int r,
                                       int c,
                                       Object obj)
Adds or updates the element at the specified row and column, as needed.

Parameters:
r - the row of the element to be updated
c - the column of the element to updated
o - the new element
See Also:
addElement, removeElementAt

All Packages  Class Hierarchy  This Package  Previous  Next  Index